//
//  CMAppDelegate.m
//  CloudMonitoring
//
//  Created by TerryChe on 2016/12/20.
//  Copyright © 2016年 TerryChe. All rights reserved.
//

#import "CMAppDelegate.h"
#import "CMDetailViewController.h"
#import "CMConfigViewController.h"

#import "PrefixHeader.pch"

#include <spawn.h>

@implementation CMAppDelegate

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    NSString *configPath = [str_cm_dir stringByAppendingPathComponent:str_cm_config];
    NSLog(@"%@ : %d", configPath, [[NSFileManager defaultManager] fileExistsAtPath:configPath]);
    
    if (![[NSFileManager defaultManager] fileExistsAtPath:configPath]) {
        //没安装监控服务
        NSLog(@"没安装监控服务");
    
        _rootViewController = [[UIStoryboard storyboardWithName:@"CMConfig" bundle:nil] instantiateInitialViewController];
    }
    else{
        //已安装
        NSLog(@"已安装");
        
        _rootViewController = [[UIStoryboard storyboardWithName:@"CMDetail" bundle:nil] instantiateInitialViewController];
    }
    
    _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _window.rootViewController = _rootViewController;
    [_window makeKeyAndVisible];
    
    return YES;
}

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskPortrait;
}

@end
